﻿namespace ExamV5.StudyInfo
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.IO;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using Wuqi.Webdiyer;

    public class FrmUserStudyReprot : Page
    {
        protected Button butExp;
        protected Button butQuery;
        protected GridView DataGridInfo;
        protected DropDownList DDLQuery;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        protected Label labRescordCount;
        protected Label labTip;
        protected LinkButton LBFirstPage;
        protected LinkButton LBLastPage;
        protected LinkButton LBNextPage;
        protected LinkButton LBPrevPage;
        private PublicFun publicFun_0 = new PublicFun();
        protected ScriptManager SM;
        protected TextBox txtEndDate;
        protected TextBox txtStartDate;
        protected UpdatePanel UPPart;

        protected AspNetPager aspPager;
        protected void butExp_Click(object sender, EventArgs e)
        {
            try
            {
                string cmdText = "";
                string key = Guid.NewGuid().ToString("N").ToUpper();
                string path = base.Server.MapPath("../") + @"\PublicFile\CountStudyInfo" + key + ".csv";
                string str3 = "";
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                StreamWriter writer = new StreamWriter(path, true, Encoding.GetEncoding("GB2312"));
                writer.WriteLine("名称信息,学习任务数,参与数,完成数,未完成数,未参与数");
                if (!(this.DDLQuery.SelectedItem.Value == "User"))
                {
                    cmdText = "select UPID,DeptName as CountName,ID as CountID,'0' as CountNum,'0' as JoinNum,'0' as SuccNum,'0' as FalseNum,'0' as NoJoinNum from DeptInfo";
                    if (this.httpCookie_2.Value != "C")
                    {
                        cmdText = cmdText + " where ID in (select b.ID from DeptInfo b where " + this.publicFun_0.GetManagDeptID(this.httpCookie_3.Value) + ")";
                    }
                }
                else
                {
                    cmdText = "select '0' as UPID, b.UserName+'['+b.UserCode+']' as CountName,b.UserCode as CountID,'0' as CountNum,'0' as JoinNum,'0' as SuccNum,'0' as FalseNum,'0' as NoJoinNum from   StudyUser a,UserInfo b where a.UserCode=b.UserCode";
                    if (this.httpCookie_2.Value != "C")
                    {
                        cmdText = cmdText + " and b.DeptID in (select b.ID from DeptInfo b where " + this.publicFun_0.GetManagDeptID(this.httpCookie_3.Value) + ")";
                    }
                    cmdText = cmdText + "  group by b.UserCode,b.UserName";
                }
                string values = "";
                cmdText = cmdText + "  order by " + this.ViewState["SortFiled"].ToString() + " " + this.ViewState["SortType"].ToString();
                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                connection.Open();
                SqlCommand command = new SqlCommand(cmdText, connection);
                SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                while (reader.Read())
                {
                    str3 = "";
                    if (this.DDLQuery.SelectedItem.Value != "User")
                    {
                        if (reader["UPID"].ToString() != "0")
                        {
                            str3 = str3 + this.publicFun_0.GetValues("select DeptName from DeptInfo where ID=" + reader["UPID"].ToString(), "DeptName") + "＼" + reader["CountName"].ToString().Trim() + ",";
                        }
                        else
                        {
                            str3 = str3 + reader["CountName"].ToString().Trim() + ",";
                        }
                        if (!((this.txtStartDate.Text.Trim() != "") ? !(this.txtEndDate.Text.Trim() != "") : true))
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct a.ID) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where c.UserCode=b.UserCode and c.DeptID='" + reader["CountID"].ToString() + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59') group by c.deptID", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct a.ID) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where c.UserCode=b.UserCode and c.DeptID='" + reader["CountID"].ToString() + "' and a.ID=b.PlanID  group by c.deptID", "CountInfo");
                        }
                        if (values.Trim() == "")
                        {
                            values = "0";
                        }
                        str3 = ((((str3 + values + ",") + this.method_1(reader["CountID"].ToString(), "A", "B") + ",") + this.method_1(reader["CountID"].ToString(), "B", "B") + ",") + this.method_1(reader["CountID"].ToString(), "C", "B") + ",") + this.method_1(reader["CountID"].ToString(), "D", "B") + ",";
                        writer.WriteLine(str3);
                    }
                    else
                    {
                        str3 = str3 + reader["CountName"].ToString().Trim() + ",";
                        if (!(this.txtStartDate.Text.Trim() != "") || !(this.txtEndDate.Text.Trim() != ""))
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.UserCode='" + reader["CountID"].ToString() + "' and a.ID=b.PlanID ", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.UserCode='" + reader["CountID"].ToString() + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59')", "CountInfo");
                        }
                        if (values.Trim() == "")
                        {
                            values = "0";
                        }
                        str3 = ((((str3 + values + ",") + this.method_1(reader["CountID"].ToString(), "A", "A") + ",") + this.method_1(reader["CountID"].ToString(), "B", "A") + ",") + this.method_1(reader["CountID"].ToString(), "C", "A") + ",") + this.method_1(reader["CountID"].ToString(), "D", "A") + ",";
                        writer.WriteLine(str3);
                    }
                }
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
                writer.Flush();
                writer.Close();
                this.labTip.Text = " 导出成功！单击【<a href='../FrmDownLoad.aspx?FileName=CountStudyInfo" + key + ".csv' target=_blank><font color=red>下载</font></a>】进行保存";
            }
            catch
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BExpErrTip", @"alert('导出数据失败！\n\n请将PublicFile目录设置为Everyone用户可修改权限！')", true);
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
            }
        }

        protected void butQuery_Click(object sender, EventArgs e)
        {
            this.DataGridInfo.PageIndex = 0;
            this.aspPager.CurrentPageIndex = 1;
            this.method_0();
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void DataGridInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.DataGridInfo.PageIndex = e.NewPageIndex;
            this.method_0();
        }

        protected void DataGridInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            string str;
            //if (e.Row.DataItemIndex == -1)
            //{
            //    this.DataGridInfo.Attributes.Add("oldValue", "#FFFFFF");
            //    this.DataGridInfo.Attributes.Add("singleValue", "#FFFFFF");
            //}
            //else
            //{
            //    e.Row.Attributes.Add("onmouseover", "this.bgColor='#F6F5F5'");
            //    if ((e.Row.DataItemIndex % 2) != 0)
            //    {
            //        e.Row.Attributes.Add("bgcolor", "#FFFFFF");
            //        e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('oldValue')");
            //    }
            //    else
            //    {
            //        e.Row.Attributes.Add("bgcolor", "#FFFFFF");
            //        e.Row.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGridInfo').getAttribute('singleValue')");
            //    }
            //}
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (this.DDLQuery.SelectedItem.Value == "User")
                {
                    if ((this.txtStartDate.Text.Trim() != "") && (this.txtEndDate.Text.Trim() != ""))
                    {
                        e.Row.Cells[1].Text = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.UserCode='" + this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString() + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59')", "CountInfo");
                    }
                    else
                    {
                        e.Row.Cells[1].Text = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.UserCode='" + this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString() + "' and a.ID=b.PlanID ", "CountInfo");
                    }
                    if (e.Row.Cells[1].Text.Trim() == "")
                    {
                        e.Row.Cells[1].Text = "0";
                    }
                    e.Row.Cells[2].Text = this.method_1(this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString(), "A", "A");
                    e.Row.Cells[3].Text = this.method_1(this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString(), "B", "A");
                    e.Row.Cells[4].Text = this.method_1(this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString(), "C", "A");
                    e.Row.Cells[5].Text = this.method_1(this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString(), "D", "A");
                }
                else
                {
                    if ((this.txtStartDate.Text.Trim() != "") ? !(this.txtEndDate.Text.Trim() != "") : true)
                    {
                        e.Row.Cells[1].Text = this.publicFun_0.GetValues("select  Count(distinct a.ID) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where c.UserCode=b.UserCode and c.DeptID='" + this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString() + "' and a.ID=b.PlanID  group by c.deptID", "CountInfo");
                    }
                    else
                    {
                        e.Row.Cells[1].Text = this.publicFun_0.GetValues("select  Count(distinct a.ID) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where c.UserCode=b.UserCode and c.DeptID='" + this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString() + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59') group by c.deptID", "CountInfo");
                    }
                    if (e.Row.Cells[1].Text.Trim() == "")
                    {
                        e.Row.Cells[1].Text = "0";
                    }
                    if (this.DataGridInfo.DataKeys[e.Row.RowIndex]["UPID"].ToString() != "0")
                    {
                        e.Row.Cells[0].Text = this.publicFun_0.GetValues("select DeptName from DeptInfo where ID=" + this.publicFun_0.CheckString(this.DataGridInfo.DataKeys[e.Row.RowIndex]["UPID"].ToString().Replace("&nbsp;", "")), "DeptName") + "＼" + e.Row.Cells[0].Text;
                    }
                    e.Row.Cells[2].Text = this.method_1(this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString(), "A", "B");
                    e.Row.Cells[3].Text = this.method_1(this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString(), "B", "B");
                    e.Row.Cells[4].Text = this.method_1(this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString(), "C", "B");
                    e.Row.Cells[5].Text = this.method_1(this.DataGridInfo.DataKeys[e.Row.RowIndex]["CountID"].ToString(), "D", "B");
                }
            }
            if (e.Row.RowType != DataControlRowType.Header)
            {
                return;
            }
            if (this.ViewState["SortType"].ToString() == " Desc")
            {
                str = this.ViewState["SortFiled"].ToString();
                if (str == null)
                {
                    goto Label_0924;
                }
                if (!(str == "CountName"))
                {
                    if (!(str == "CountNum"))
                    {
                        goto Label_0924;
                    }
                    e.Row.Cells[1].Controls.Add(new LiteralControl("↑"));
                }
                else
                {
                    e.Row.Cells[0].Controls.Add(new LiteralControl("↑"));
                }
                return;
            }
            str = this.ViewState["SortFiled"].ToString();
            if (str != null)
            {
                if (!(str == "CountName"))
                {
                    if (!(str == "CountNum"))
                    {
                        goto Label_0879;
                    }
                    e.Row.Cells[1].Controls.Add(new LiteralControl("↓"));
                }
                else
                {
                    e.Row.Cells[0].Controls.Add(new LiteralControl("↓"));
                }
                return;
            }
            Label_0879:
            e.Row.Cells[0].Controls.Add(new LiteralControl("↓"));
            return;
            Label_0924:
            e.Row.Cells[0].Controls.Add(new LiteralControl("↑"));
        }

        protected void DataGridInfo_Sorting(object sender, GridViewSortEventArgs e)
        {
            string sortExpression = e.SortExpression;
            if (this.ViewState["SortFiled"].ToString() == sortExpression)
            {
                if (this.ViewState["SortType"].ToString() == " Desc")
                {
                    this.ViewState["SortType"] = " ASC";
                }
                else
                {
                    this.ViewState["SortType"] = " Desc";
                }
            }
            else
            {
                this.ViewState["SortFiled"] = e.SortExpression;
            }
            this.method_0();
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void DataGridInfo_PreRender(object sender, EventArgs e)
        {
            // 使用<TH>替换<TD> 
            this.DataGridInfo.UseAccessibleHeader = true;
            //HeaderRow将被<thead>包裹，数据行将被<tbody>包裹
            this.DataGridInfo.HeaderRow.TableSection = TableRowSection.TableHeader;
        }

        protected void aspPager_PageChanged(object sender, EventArgs e)
        {
            this.DataGridInfo.PageIndex = this.aspPager.CurrentPageIndex - 1;
            this.method_0();
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        protected void DDLDept_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DataGridInfo.PageIndex = 0;
            this.method_0();
        }

        protected void LBFirstPage_Click(object sender, EventArgs e)
        {
            this.DataGridInfo.PageIndex = 0;
            this.method_0();
        }

        protected void LBLastPage_Click(object sender, EventArgs e)
        {
            if (this.DataGridInfo.PageCount > 0)
            {
                this.DataGridInfo.PageIndex = this.DataGridInfo.PageCount - 1;
                this.method_0();
            }
        }

        protected void LBNextPage_Click(object sender, EventArgs e)
        {
            if (this.DataGridInfo.PageIndex < (this.DataGridInfo.PageCount - 1))
            {
                this.DataGridInfo.PageIndex++;
                this.method_0();
            }
        }

        protected void LBPrevPage_Click(object sender, EventArgs e)
        {
            if (this.DataGridInfo.PageIndex > 0)
            {
                this.DataGridInfo.PageIndex--;
                this.method_0();
            }
        }

        private void method_0()
        {
            string selectCommandText = "";
            if (!(this.DDLQuery.SelectedItem.Value == "User"))
            {
                selectCommandText = "select UPID,DeptName as CountName,ID as CountID,'0' as CountNum,'0' as JoinNum,'0' as SuccNum,'0' as FalseNum,'0' as NoJoinNum from DeptInfo";
                if (this.httpCookie_2.Value != "C")
                {
                    selectCommandText = selectCommandText + " where ID in (select b.ID from DeptInfo b where " + this.publicFun_0.GetManagDeptID(this.httpCookie_3.Value) + ")";
                }
            }
            else
            {
                selectCommandText = "select  '0' as UPID,b.UserName+'['+b.UserCode+']' as CountName,b.UserCode as CountID,'0' as CountNum,'0' as JoinNum,'0' as SuccNum,'0' as FalseNum,'0' as NoJoinNum from   StudyUser a,UserInfo b where a.UserCode=b.UserCode";
                if (this.httpCookie_2.Value != "C")
                {
                    selectCommandText = selectCommandText + " and b.DeptID in (select b.ID from DeptInfo b where " + this.publicFun_0.GetManagDeptID(this.httpCookie_3.Value) + ")";
                }
                selectCommandText = selectCommandText + "  group by b.UserCode,b.UserName";
            }
            selectCommandText = selectCommandText + "  order by " + this.ViewState["SortFiled"].ToString() + " " + this.ViewState["SortType"].ToString();
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "DataInfo");
            this.DataGridInfo.DataSource = dataSet.Tables["DataInfo"].DefaultView;
            this.DataGridInfo.DataBind();
            this.labRescordCount.Text = "总共&nbsp;<i>" + dataSet.Tables["DataInfo"].Rows.Count.ToString() + "</i>&nbsp;条记录&nbsp;<b>" + Convert.ToString((int)(this.DataGridInfo.PageIndex + 1)) + "/" + this.DataGridInfo.PageCount.ToString() + "</b>&nbsp;页&nbsp;";
            this.aspPager.RecordCount = dataSet.Tables["DataInfo"].Rows.Count;
            adapter.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
        }

        private string method_1(string string_0, string string_1, string string_2)
        {
            string values = "0";
            if (string_2.Trim() == "A")
            {
                switch (string_1)
                {
                    case "A":
                        if (!(this.txtStartDate.Text.Trim() != "") || !(this.txtEndDate.Text.Trim() != ""))
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.LoginIP<>'' and  b.UserCode='" + string_0 + "' and a.ID=b.PlanID ", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.LoginIP<>'' and b.UserCode='" + string_0 + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59')", "CountInfo");
                        }
                        break;

                    case "B":
                        if ((this.txtStartDate.Text.Trim() != "") ? !(this.txtEndDate.Text.Trim() != "") : true)
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.LoginIP<>'' and a.StudyLongTime*60<=b.CountTime and  b.UserCode='" + string_0 + "' and a.ID=b.PlanID ", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.LoginIP<>'' and a.StudyLongTime*60<=b.CountTime and b.UserCode='" + string_0 + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59')", "CountInfo");
                        }
                        break;

                    case "C":
                        if (!((this.txtStartDate.Text.Trim() != "") ? !(this.txtEndDate.Text.Trim() != "") : true))
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.LoginIP<>'' and a.StudyLongTime*60>b.CountTime and b.UserCode='" + string_0 + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59')", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.LoginIP<>'' and a.StudyLongTime*60>b.CountTime and  b.UserCode='" + string_0 + "' and a.ID=b.PlanID ", "CountInfo");
                        }
                        break;

                    case "D":
                        if ((this.txtStartDate.Text.Trim() != "") && (this.txtEndDate.Text.Trim() != ""))
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.LoginIP='' and b.UserCode='" + string_0 + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59')", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(*) as CountInfo from  StudyPlanInfo a,StudyUser b where b.LoginIP='' and  b.UserCode='" + string_0 + "' and a.ID=b.PlanID ", "CountInfo");
                        }
                        break;
                }
            }
            else
            {
                switch (string_1)
                {
                    case "A":
                        if (!((this.txtStartDate.Text.Trim() != "") ? !(this.txtEndDate.Text.Trim() != "") : true))
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct c.userCode) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where b.LoginIP<>'' and c.UserCode=b.UserCode and c.DeptID='" + string_0 + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59') group by c.deptID", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct c.userCode) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where b.LoginIP<>'' and c.UserCode=b.UserCode and c.DeptID='" + string_0 + "' and a.ID=b.PlanID  group by c.deptID", "CountInfo");
                        }
                        break;

                    case "B":
                        if ((this.txtStartDate.Text.Trim() != "") ? !(this.txtEndDate.Text.Trim() != "") : true)
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct c.userCode) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where b.LoginIP<>'' and a.StudyLongTime*60<=b.CountTime and  c.UserCode=b.UserCode and c.DeptID='" + string_0 + "' and a.ID=b.PlanID  group by c.deptID", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct c.userCode) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where b.LoginIP<>'' and a.StudyLongTime*60<=b.CountTime and  c.UserCode=b.UserCode and c.DeptID='" + string_0 + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59') group by c.deptID", "CountInfo");
                        }
                        break;

                    case "C":
                        if ((this.txtStartDate.Text.Trim() != "") ? !(this.txtEndDate.Text.Trim() != "") : true)
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct c.userCode) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where b.LoginIP<>'' and a.StudyLongTime*60>b.CountTime and  c.UserCode=b.UserCode and c.DeptID='" + string_0 + "' and a.ID=b.PlanID  group by c.deptID", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct c.userCode) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where b.LoginIP<>'' and a.StudyLongTime*60>b.CountTime and  c.UserCode=b.UserCode and c.DeptID='" + string_0 + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59') group by c.deptID", "CountInfo");
                        }
                        break;

                    case "D":
                        if ((this.txtStartDate.Text.Trim() != "") ? !(this.txtEndDate.Text.Trim() != "") : true)
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct c.userCode) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where b.LoginIP='' and c.UserCode=b.UserCode and c.DeptID='" + string_0 + "' and a.ID=b.PlanID  group by c.deptID", "CountInfo");
                        }
                        else
                        {
                            values = this.publicFun_0.GetValues("select  Count(distinct c.userCode) as CountInfo,c.deptID from  StudyPlanInfo a,StudyUser b,UserInfo c where b.LoginIP='' and c.UserCode=b.UserCode and c.DeptID='" + string_0 + "' and a.ID=b.PlanID and a.InputTime>=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtStartDate.Text.Trim()) + " 00:00:00') and a.InputTime<=Convert(dateTime,'" + this.publicFun_0.CheckString(this.txtEndDate.Text.Trim()) + " 23:59:59') group by c.deptID", "CountInfo");
                        }
                        break;
                }
            }
            if (values.Trim() == "")
            {
                values = "0";
            }
            return values;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if ((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false)
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                if (Convert.ToInt32(ConfigurationManager.ConnectionStrings["OnlineNum"].ConnectionString) != 0x3a)
                {
                    if (!base.IsPostBack)
                    {
                        if (!(this.publicFun_0.ReturnPaperData() != "Yes"))
                        {
                            this.ViewState["SortFiled"] = "CountName";
                            this.ViewState["SortType"] = " Desc";
                            this.method_0();
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')", true);
                        }
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BTHB", "alert('该版本为特惠版，此功能未开放！')", true);
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }
    }
}

